package com.jie.commonlib.network.bean

import androidx.annotation.Keep
import com.jie.commonlib.network.http.HttpCommonConstant
import java.util.ArrayList

/**
 * 列表数据分页信息实体
 *
 * @author ZhangJun
 * @date 2017/11/16
 */
@Keep
class PageInfo<E> {
    /** 当前页码  */
    var pageNum = 0

    /** 每页显示条数  */
    var pageSize = 0

    /** 数据总数  */
    var dataCount = 0

    /** 总页数  */
    var totalPage = 0

    /** 开始行  */
    var startRow = 0

    /** 数据集  */
    var pageData: ArrayList<E>? = null

    constructor() {}
    constructor(
        pageNum: Int,
        pageSize: Int,
        dataCount: Int,
        totalPage: Int,
        startRow: Int,
        pageData: ArrayList<E>?
    ) {
        this.pageNum = pageNum
        this.pageSize = pageSize
        this.dataCount = dataCount
        this.totalPage = totalPage
        this.startRow = startRow
        this.pageData = pageData
    }

    /**
     * 判断是否为第一页
     */
    val isFirstPage: Boolean
        get() = pageNum == HttpCommonConstant.PAGE_START_NUM

    /**
     * 判断是否为最后一页
     */
    val isLastPage: Boolean
        get() = pageNum == totalPage

    override fun toString(): String {
        return "PageInfo{" +
                "pageNum=" + pageNum +
                ", pageSize=" + pageSize +
                ", dataCount=" + dataCount +
                ", totalPage=" + totalPage +
                ", startRow=" + startRow +
                ", pageData=" + pageData +
                '}'
    }
}